﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


/// <summary>
/// Summary description for DALCustomer
/// </summary>
public class DALCustomer : BaseDAL
{

    public DALCustomer()
    {

    }

    public void insertCustomer(tblCustomer customer)
    {
        db.tblCustomers.InsertOnSubmit(customer);
        db.SubmitChanges();
    }

    public tblCustomer login(string email, string password)
    {
        return db.tblCustomers.SingleOrDefault(c => c.Email == email && c.Password == password);
    }

    public tblCustomer getPassword(string email)
    {
        return db.tblCustomers.SingleOrDefault(c => c.Email == email);
    }
    public void updateCustomer(tblCustomer customer) 
    {
        tblCustomer update = db.tblCustomers.SingleOrDefault(c => c.ID == customer.ID);
        update.Password  = customer.Password;
        update.Province = customer.Province;
        update.Street = customer.Street;
        update.Block = customer.Block;
        update.City = customer.City;
        update.Country = customer.Country;
        update.Contact = customer.Contact;
        db.SubmitChanges();
    }

    public bool isExist(string email)
    {
        return db.tblCustomers.Count(c => c.Email == email && c.IsMember == true) > 0;
    }
}
